<?php
require_once 'PHPUnit/Framework.php';
require_once 'TVB/PWORKS/util/CommonUtil.class.php';

class VideoUpdateAction extends PHPUnit_Framework_TestCase
{
    protected function setUp()
    {
        $this->url = 'http://pdes.tvb.com/update_video.html?act=edit&ut=TRUE';
    }

    protected function tearDown()
    {
        unset($this->url);
    }

    public function testSucess()
    {
        $param_video = array(
            'id'                => 195,
            'programme_id'      => 29,
            'online_date_time'  => '2010-01-29 01:01:01',
            'offline_date_time' => '2010-01-30 01:01:01',
            'onair_episode_no'  => 2, 
            'mdes_status'       => 2,
            'title'             => 'Donald UT',
            'first_time_onair'  => '2010-01-29 01:01:01',
            'country_allow_deny'    => 'allow',
            'country[]'             => 'HK',
            'copyright_owner'       => 'Owner Test',
        );
        $param_chapter = array(
            'chapter_id[]'          => 66,
            'chapter_title_cn[]'    => 'Donald Chapter UT',
            'chapter_title_en[]'    => 'Donald Chapter UT ENG',
            'chapter_in_time_hour[]'    => '00',
            'chapter_in_time_minute[]'  => '00',
            'chapter_in_time_second[]'  => '00',
            'chapter_out_time_hour[]'   => '00',
            'chapter_out_time_minute[]' => '00',
            'chapter_out_time_second[]' => '00',
            'chapter_description_cn[]'  => 'DESC CHI',
            'chapter_description_en[]'  => 'DESC ENG',
            'cast_dict_id[66][0]'       => '1',
            'cast_dict_id[66][1]'       => '2',
            'tvbcom_cat_id[66][0]'      => '3',
            'tvbcom_cat_id[66][1]'      => '21',
            'tag[1][66][0]'             => '4008',
            'tag[1][66][1]'             => '4015',
            'new_tag[1][66][]'          => 'naldChapterTagsNew',
            'tag[4][66][0]'             => 410,
            'tag[4][66][1]'             => 4043,
            'new_tag[4][66][]'          => 'DonaldChapterLibTagsNew',
        );

        $param = array_merge($param_video, $param_chapter);
        $result = CommonUtil::curl_test($this->url, $param);
        var_dump($result);
    }

    public function testPublishDatetimeAndExpireDatetime()/*{{{*/
    {
        $param = array(
            'id'            => 195,
            'programme_id'  => 29,
        );
        $result = CommonUtil::curl_test($this->url, $param);
    }/*}}}*/

    public function testOnairEpisodeNoError()/*{{{*/
    {
        $param = array(
            'id'                => 195,
            'programme_id'      => 29,
            'online_date_time'  => '2010-01-29 01:01:01',
            'offline_date_time' => '2010-01-30 01:01:01',
            'onair_episode_no'  => 1111,
        );
        $result = CommonUtil::curl_test($this->url, $param);
    }/*}}}*/

    public function testChapterTitle()/*{{{*/
    {
        $param_video = array(
            'id'                => 195,
            'programme_id'      => 29,
            'online_date_time'  => '2010-01-29 01:01:01',
            'offline_date_time' => '2010-01-30 01:01:01',
            'onair_episode_no'  => 2, 
            'mdes_status'       => 2,
            'title'             => 'Donald UT',
            'first_time_onair'  => '2010-01-29 01:01:01',
            'country_allow_deny'    => 'allow',
            'country[]'             => 'HK',
            'copyright_owner'       => 'Owner Test',
        );
        $param_chapter = array(
            'chapter_id[]'          => 66,
            'chapter_title_cn[]'    => NULL,
            'chapter_title_en[]'    => NULL,
        );

        $param = array_merge($param_video, $param_chapter);
        $result = CommonUtil::curl_test($this->url, $param);
    }/*}}}*/

    public function testChapterInTimeError()/*{{{*/
    {
        $param_video = array(
            'id'                => 195,
            'programme_id'      => 29,
            'online_date_time'  => '2010-01-29 01:01:01',
            'offline_date_time' => '2010-01-30 01:01:01',
            'onair_episode_no'  => 2, 
            'mdes_status'       => 2,
            'title'             => 'Donald UT',
            'first_time_onair'  => '2010-01-29 01:01:01',
            'country_allow_deny'    => 'allow',
            'country[]'             => 'HK',
            'copyright_owner'       => 'Owner Test',
        );
        $param_chapter = array(
            'chapter_id[]'          => 66,
            'chapter_title_cn[]'    => 'Donald Chapter UT',
            'chapter_title_en[]'    => NULL,
        );

        $param = array_merge($param_video, $param_chapter);
        $result = CommonUtil::curl_test($this->url, $param);
    }/*}}}*/

}
?>
